<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %>

	<style>
	
		.selected{
			background: #f5f5f5;
		}
		
		.hide{
   			 display:none;
		}

	</style>
	
	<script type="text/javascript">
	$(document).ready(function(){
		$("#table #rows").click(function(){
			   $(this).addClass('selected').siblings().removeClass('selected');    
			   var idcongvan = $(this).find('td:eq(0)').html();
			  	$('#kyhieuCV_gv').val(idcongvan);
			  	$('#kyhieuCV_bm').val(idcongvan);
			  	$('#btnphanconggiangvien').prop('disabled', false);
			  	$('#btnphancongbomon').prop('disabled', false);
			  })
			  
	});	

	</script>
	 <script type="text/javascript">
		$(document).ready(function(){
		    $("#dropdown").change(function(){
		    var value=$(this).val();
		        $("#listbox option").removeClass("hide");
		        $("#listbox option[value="+value+"]").addClass("hide");
		        $("#display").text("");
		    });
		});
	</script>
	
	<script type="text/javascript">
		$(document).ready(function() {
			$('#cc').multiselect();
			$('#bcc').multiselect();
		});
</script>
	

<button type="button" class="btn btn-primary" data-toggle="modal" data-target=".phanconggiangvien" disabled id="btnphanconggiangvien">Phân công giảng viên</button>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target=".phancongbomon" disabled id="btnphancongbomon">Phân công bộ môn</button>

<!-- MODAL PHAN CONG GIANG VIEN -->
<div class="modal fade phanconggiangvien" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id="myModalLabel">Phân công giảng viên</h4>
</div>
<div class="modal-body">
	<form action="phanconggiangvien"  method="post" class="form-horizontal" accept-charset="UTF-8">
		<div class="form-group">
			<label for="kyhieuCV" class="col-lg-3 control-label">Mã công văn đến</label>
			<div class="col-lg-9">
			<input class="form-control" id="kyhieuCV_gv" name="idcongvanden" placeholder="Ký hiệu công văn" type="text">
			</div>
		</div><!-- end form-group-->

		<div class="form-group">
			<label for="hancuoi" class="col-lg-3 control-label">Hạn cuối</label>
			<div class="col-lg-9">
			 <input class="form-control" type="text" name="hancuoi" id="datepicker_gv" placeholder="Hạn cuối">
			</div>
		</div><!-- end form-group-->
	<div class="form-group">
			<label for="hancuoi" class="col-lg-3 control-label">To</label>
			<div class="col-lg-9">
			 <select class="form-control" id="dropdown" name="idcanbo">
			 	<option value="">--Tên giảng viên --</option>
				<c:forEach items="${listGiangvien}" var="gv">
					<option value="${gv.canbo.idCanBo}">${gv.canbo.tenCanBo}</option>
				</c:forEach>
			</select>
			</div>
		</div><!-- end form-group-->
		<div class="form-group">
			<label for="hancuoi" class="col-lg-3 control-label">CC</label>
			<div class="col-lg-9">
			 <select class="form-control" id="cc" name="idcanbo" multiple="multiple">
				<c:forEach items="${listGiangvien}" var="gv">
					<option value="${gv.canbo.idCanBo}">${gv.canbo.tenCanBo}</option>
				</c:forEach>
			</select>
			</div>
		</div><!-- end form-group-->
		<div class="form-group">
			<label for="hancuoi" class="col-lg-3 control-label">BCC</label>
			<div class="col-lg-9">
			 <select class="form-control" id="bcc" name="idcanbo" multiple="multiple">
				<c:forEach items="${listGiangvien}" var="gv">
					<option value="${gv.canbo.idCanBo}">${gv.canbo.tenCanBo}</option>
				</c:forEach>
			</select>
			</div>
		</div><!-- end form-group-->
		<%-- <div class="form-group">
			<label for="hancuoi" class="col-lg-3 control-label">Phân công</label>
			<div class="col-lg-5">
			 <select class="form-control" id="listbox" name="idcanbo" multiple>
				<c:forEach items="${listGiangvien}" var="gv">
					<option value="${gv.canbo.idCanBo}">${gv.canbo.tenCanBo}</option>
				</c:forEach>
			</select>
			</div>
			<div class="col-lg-4">
			 <textarea  class="form-control" rows="3" id="display" name="listGiangVien" placeholder="List Giảng viên"></textarea>
			</div>
		</div><!-- end form-group--> 
		<script type="text/javascript" src="resources/js/listbox.js"></script>
 --%>


		<button type="button" class="btn btn-default" data-dismiss="modal">Đóng</button>
		<button type="submit" class="btn btn-primary">Lưu</button>

	</form>
</div><!-- END modal-body -->
</div><!-- END modal-content -->
</div><!-- END modal-dialog modal-lg -->
</div><!-- END modal fade bs-example-modal-lg -->


<!--END MODAL PHAN CONG GIANG VIEN-->


<!-- MODAL PHAN CONG GIANG VIEN -->


<div class="modal fade phancongbomon" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id="myModalLabel">Phân công giảng viên</h4>
</div>
<div class="modal-body">
	<form action="phancongbomon"  method="post" class="form-horizontal" accept-charset="UTF-8">
		<div class="form-group">
			<label for="kyhieuCV" class="col-lg-3 control-label">Mã công văn đến</label>
			<div class="col-lg-9">
			<input class="form-control" id="kyhieuCV_bm" name="idcongvanden" placeholder="Ký hiệu công văn" type="text">
			</div>
		</div><!-- end form-group-->

		<div class="form-group">
			<label for="hancuoi" class="col-lg-3 control-label">Hạn cuối</label>
			<div class="col-lg-9">
			 <input class="form-control" type="text" name="hancuoi" id="datepicker_bm" placeholder="Hạn cuối">
			</div>
		</div><!-- end form-group-->
	<div class="form-group">
			<label for="phancong" class="col-lg-3 control-label">Phân công</label>
			<div class="col-lg-9">
			 <select class="form-control" id="dropkdown" name="idbomon">
				<c:forEach items="${listBomon}" var="bm">
					<option value="${bm.idBoMon}">${bm.tenBoMon}</option>
				</c:forEach>
			</select>
			</div>
		</div><!-- end form-group-->
			<div class="form-group">
			<label for="hancuoi" class="col-lg-3 control-label">Phân công</label>
			<div class="col-lg-9">
			 <select class="form-control" id="lisltbox" name="idbomon" multiple>
				<c:forEach items="${listBomon}" var="bm">
					<option value="${bm.idBoMon}">${bm.tenBoMon}</option>
				</c:forEach>
			</select>
			</div>
		</div><!-- end form-group-->
		<button type="button" class="btn btn-default" data-dismiss="modal">Đóng</button>
		<button type="submit" class="btn btn-primary">Lưu</button>

	</form>
</div><!-- END modal-body -->
</div><!-- END modal-content -->
</div><!-- END modal-dialog modal-lg -->
</div><!-- END modal fade bs-example-modal-lg -->


<!--END MODAL PHAN CONG BO MON-->



<!-- MODAL CHI TIET PHAN CONG GIANG VIEN-->
<div class="modal fade chitietphancong" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id="myModalLabel">Phân công giảng viên</h4>
</div>
<div class="modal-body">
</div><!-- END modal-body -->
</div><!-- END modal-content -->
</div><!-- END modal-dialog modal-lg -->
</div><!-- END modal fade bs-example-modal-lg -->

<!-- MODAL CHI TIET PHAN CONG GIANG VIEN-->
	
	

<c:if test="${!empty listCongVan}">
	<table class="table table-hover" id="table">
		<tr>
			<th width="80">Mã Công Văn</th>
			<th width="150">Trích Yếu</th>
			<th width="120">File Đính Kèm</th>
			<th width="120">Ngày Nhận</th>
			<th width="80">Nơi Gửi</th>
			<th width="80">Chi tiết phân công</th>
			<th width="80">Xem phân công</th>
			
		</tr>
		<c:forEach items="${listCongVan}" var="congvan">
			<c:if test="${!empty congvan.congvanden.idCongVanDen}">
			<tr id="rows">
				<td>${congvan.congvanden.idCongVanDen}</td>
				<td>${congvan.trichYeu}</td>
				<td><a href="download/${congvan.congvanden.idCongVanDen}">${congvan.fileName}</a></td>
				<td><fmt:formatDate value="${congvan.congvanden.ngayNhan}" pattern="dd-MM-yyyy" /></td>
				<td>${congvan.congvanden.noiGui}</td>
				<td><a class="btn btn-primary" href="<c:url value='/chitietphancong/${congvan.congvanden.idCongVanDen}' />">Chi tiết</a></td>
				<td><a class="btn btn-primary" href="<c:url value='/xemphancong/${congvan.congvanden.idCongVanDen}' />">Xem</a></td>
			 </tr>
			 </c:if>
		</c:forEach>
	</table>
</c:if>
